home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / GW AdaEd 1.4.2 / GWAdaDemos / GWU Demos / roomwind.adb < prev    next >
Text File  |  1993-12-24  |  3KB  |  105 lines

  1. --::::::::::
  2. --roomwind.adb
  3. --::::::::::
  4. WITH Windows;
  5. WITH Chop;
  6. WITH Phil;
  7. WITH Calendar; 
  8. PRAGMA Elaborate(Phil);
  9. PACKAGE BODY Room IS
  10.  
  11.   Phils:      ARRAY(Table_Type) OF Phil.Philosopher;
  12.   Phil_Windows: ARRAY(Table_Type) OF Windows.Window;
  13.  
  14.   TYPE Phil_Names IS (Dijkstra, Texel, Booch, Ichbiah, Stroustrup);
  15.  
  16.   TASK BODY Head_Waiter IS
  17.  
  18.     T : Integer; 
  19.     Start_Time: Calendar.Time;
  20.  
  21.   BEGIN
  22.  
  23.     ACCEPT Open_The_Room;
  24.     Start_Time := Calendar.Clock;
  25.  
  26.     Phil_Windows(1) := Windows.Open((1,23),7,30);
  27.     Windows.Borders(Phil_Windows(1),'+','|','-');
  28.     Windows.Title(Phil_Windows(1), "Eddy Dijkstra",'-');
  29.     Phils(1).Come_To_Life(1,1,2);
  30.  
  31.     Phil_Windows(3) := Windows.Open((9,50),7,30);    
  32.     Windows.Borders(Phil_Windows(3),'+','|','-');
  33.     Windows.Title(Phil_Windows(3), "Grady Booch",'-');
  34.     Phils(3).Come_To_Life(3,3,4);
  35.  
  36.     Phil_Windows(2) := Windows.Open((9,2),7,30); 
  37.     Windows.Borders(Phil_Windows(2),'+','|','-');
  38.     Windows.Title(Phil_Windows(2), "Putnam Texel",'-');
  39.     Phils(2).Come_To_Life(2,2,3);
  40.  
  41.     Phil_Windows(5) := Windows.Open((17,41),7,30); 
  42.     Windows.Borders(Phil_Windows(5),'+','|','-');
  43.     Windows.Title(Phil_Windows(5), "Bjarne Stroustrup",'-');
  44.     Phils(5).Come_To_Life(5,1,5);
  45.  
  46.     Phil_Windows(4) := Windows.Open((17,8),7,30); 
  47.     Windows.Borders(Phil_Windows(4),'+','|','-');
  48.     Windows.Title(Phil_Windows(4), "Jean Ichbiah",'-');
  49.     Phils(4).Come_To_Life(4,4,5);
  50.  
  51.     LOOP
  52.       SELECT
  53.         ACCEPT Report_State(Which_Phil: Table_Type;
  54.                          State: Phil.States;
  55.                          How_Long: Natural := 0) DO
  56.           T := Integer(Calendar."-"(Calendar.Clock,Start_Time));
  57.           Windows.Put(Phil_Windows(Which_Phil),
  58.             "T=" & Integer'Image(T) & " ");
  59.           CASE State IS
  60.             WHEN Phil.Breathing =>
  61.               Windows.Put(Phil_Windows(Which_Phil), "Breathing...");
  62.               Windows.New_Line(Phil_Windows(Which_Phil));
  63.  
  64.             WHEN Phil.Thinking =>
  65.               Windows.Put(Phil_Windows(Which_Phil),
  66.                          "Thinking"
  67.                          & Integer'Image(How_Long)
  68.                          & " seconds.");
  69.               Windows.New_Line(Phil_Windows(Which_Phil));
  70.  
  71.             WHEN Phil.Eating =>
  72.               Windows.Put(Phil_Windows(Which_Phil),
  73.                          "Eating"   
  74.                          & Integer'Image(How_Long)
  75.                          & " seconds.");
  76.               Windows.New_Line(Phil_Windows(Which_Phil));
  77.  
  78.             WHEN Phil.Done_Eating =>
  79.               Windows.Put(Phil_Windows(Which_Phil), "Yum-yum (burp)");
  80.               Windows.New_Line(Phil_Windows(Which_Phil));
  81.  
  82.             WHEN Phil.Got_One_Stick =>
  83.               Windows.Put(Phil_Windows(Which_Phil), 
  84.                          "First chopstick"
  85.                           & Integer'Image(How_Long));
  86.               Windows.New_Line(Phil_Windows(Which_Phil));
  87.  
  88.             WHEN Phil.Got_Other_Stick =>
  89.               Windows.Put(Phil_Windows(Which_Phil), 
  90.                          "Second chopstick"
  91.                           & Integer'Image(How_Long));
  92.               Windows.New_Line(Phil_Windows(Which_Phil));
  93.  
  94.           END CASE;
  95.  
  96.          END Report_State;
  97.         OR
  98.           TERMINATE;
  99.         END SELECT;
  100.  
  101.       END LOOP;
  102.  
  103.     END Head_Waiter;
  104.  
  105. END Room;